package com.hj.user.dao;

import com.hj.user.domain.UserInfo;

import java.util.ArrayList;

public class UserInfoDaoImpl implements UserInfoDao {
    public static final ArrayList<UserInfo> list = new ArrayList<>();
    static {
        list.add(new UserInfo(1001,"王小明","2024-7-1"));
        list.add(new UserInfo(1002,"刘小红","2024-7-12"));
        list.add(new UserInfo(1003,"张小强","2024-7-10"));
    }

    @Override
    public void mainMenu() {
            System.out.println("========欢迎使用超市用户管理系统========");
            System.out.println("1. 查询会员信息");
            System.out.println("2. 删除会员");
            System.out.println("3. 新增会员信息");
            System.out.println("4. 退出");
            System.out.println("======================================");
            System.out.println("请输入您的选择:");
    }

    @Override
    public void searchAll() {
        System.out.println("编号\t姓名\t入会日期");
        for (UserInfo userInfo : list) {
            System.out.println(userInfo.getId()+"\t"+userInfo.getName()+"\t"+userInfo.getDate());
        }
    }

    @Override
    public void deleteUserInfo(int id) {
        list.remove(id);
    }

    @Override
    public void addUserInfo(UserInfo user) {
        list.add(user);
    }
}
